package cn.wolfcode.trip.base.domain;

import com.alibaba.druid.support.json.JSONUtils;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Getter;
import lombok.Setter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 攻略分类
 */
@Getter
@Setter
@JsonIgnoreProperties("handler")
public class StrategyCatalog extends  BaseDomain{


    //分类名称
    private String name;

    //该分类所属的大攻略
    private Strategy strategy;

    //排序
    private Integer sequence;

    //分类状态
    private Boolean state=false;

    //关联分类下的文章集合
    private List<StrategyDetail> listDetails=new ArrayList<>();

    //状态形容词
    public String getStateName(){
        return state?"启用":"禁用";
    }

    //json字符串
    public String getJsonString(){
        Map<String,Object> map=new HashMap<>();
        map.put("id",id);
        map.put("name",name);
        if(strategy!=null){

            map.put("strategyId",strategy.getId());
        }
        map.put("sequence",sequence);
        if(state){
            map.put("state",1);
        }else {
            map.put("state",-1);
        }
        return JSONUtils.toJSONString(map);
    }

}